<?php

/**
 * Subclass for performing query and update operations on the 'hc_picture' table.
 *
 * 
 *
 * @package lib.model
 */ 
class PicturePeer extends BasePicturePeer
{
  /**
   * supprime physiquement les images
   * du  disque avant suppression dans la base
   */
  public static function doPhysicDelete($values, $con = null)
  {
    $pictures = self::doSelect($values);
        
    foreach ($pictures as $picture)
    {
      $currentDir = 'gallery_'.$picture->getGallery()->getId();
      $currentFile = $picture->getPath();
      
      $absCurrentFile = sfConfig::get('sf_web_dir').'/admin/uploads/galleries/'.$currentDir.'/'.$currentFile;
            
      if (is_readable($absCurrentFile))
      {
        unlink($absCurrentFile);
      }
      
      $absCurrentThumbnailFile = sfConfig::get('sf_web_dir').'/admin/uploads/galleries/'.$currentDir.'/thumbnail/'.$currentFile;
      
      if (is_readable($absCurrentThumbnailFile))
      {
        unlink($absCurrentThumbnailFile);
      }
    }
  }
}
